package main

import (
	"context"
	"fmt"
	"github.com/coreos/etcd/clientv3"
	"time"
)

func main() {
	cli, err := clientv3.New(clientv3.Config{Endpoints: []string{"localhost:2379"},
		DialTimeout: 5 * time.Second,
	})
	if err != nil {
		fmt.Println(err)
	}
	watch := cli.Watch(context.Background(), "username")
	for wresp := range watch {
		for _, ev := range wresp.Events {
			fmt.Println(111111111, ev.Type, string(ev.Kv.Key), string(ev.Kv.Value))
		}
	}
}
